//柱状图
export function columnarEcharts (xAxisData, data, title) {
  return {
    title: {
      text: title,
      subtext: 'Quantity Statistics',
      left: 'center'
    },
    grid: {
      left: "2.5%",
      right: "0%",
      bottom: "4%",
      top: "25%",
      containLabel: true
    },
    tooltip: {
      trigger: 'axis',
    },
    legend: {
      data: xAxisData
    },
    xAxis: {
      type: 'category',
      data: xAxisData,
      axisLabel: {
        interval: 0,
        rotate: -30,//-30度角倾斜显示
      }
    },
    yAxis: {
      axisTick: {
        show: false
      },
      axisLine: {
        show: false
      },
      type: 'value'
    },
    series: [
      {
        data: data,
        barWidth: 20,
        type: 'bar'
      }
    ]
  };
}

//饼图
export function annularEchar (data, title) {
  return {
    title: {
      text: title,
      subtext: 'State Statistics',
      left: 'center',
    },
    grid: {
      left: "0%",
      right: "2.5%",
      bottom: "4%",
      top: "0%",
      containLabel: true
    },
    tooltip: {
      trigger: 'item',
      formatter (item) {
        return item.marker + item.name + item.value + "%"
      }
    },
    legend: {
      orient: 'vertical',
      right: 15,
      top: 10
    },
    series: [
      {
        type: 'pie',
        radius: '50%',
        center: ["50%", "60%"],
        data: data,
        itemStyle: {
          "normal": {
            "borderWidth": 1, // 间距的宽度
            "borderColor": '#fff', //背景色
          }
        },
        emphasis: {
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: 'rgba(0, 0, 0, 0.5)'
          }
        }
      }
    ]
  }
}
